from django.db import models
from django.contrib.auth.models import AbstractUser
from datetime import datetime
# Create your models here.
class UserProfile(AbstractUser):
    nick_name = models.CharField(max_length=50,verbose_name=u"用户名")
    birthday = models.DateField(verbose_name=u"生日",null=True,blank=True)
    gender = models.CharField(max_length=50,choices=(('male',u'男'),('female','女')),default='female',verbose_name=u"性别")
    address = models.CharField(max_length=50,verbose_name=u"地址")
    mobile = models.CharField(max_length=50,verbose_name=u"手机", null=True, blank=True)
    image = models.ImageField(upload_to='uploads/user/%Y/%m/%d',default='uploads/user/default.png',verbose_name='头像')
    class Meta:
        verbose_name = u"用户信息"
        verbose_name_plural=verbose_name

    def __unicode__(self):
        return self.username

class EmailVerifuRecord(models.Model):
    code = models.CharField(max_length=50,verbose_name=u"验证码")
    email = models.EmailField(max_length=50,verbose_name=u"邮箱",null=True,blank=True)
    send_type = models.CharField(max_length=50, choices=(('register', u'注册'), ('forget', '忘记密码')),verbose_name=u"类型")
    send_time = models.DateTimeField(default=datetime.now,verbose_name='发送时间')
    class Meta:
        verbose_name = u"邮箱验证码"
        verbose_name_plural=verbose_name


class Banner(models.Model):
    title = models.CharField(max_length=50,verbose_name=u"标题")
    image = models.ImageField(upload_to='uploads/banner/%Y/%m/%d',verbose_name='轮播图')
    url = models.CharField(max_length=200, verbose_name=u"访问地址")
    index = models.IntegerField(default=100,verbose_name=u"顺序")
    add_time = models.DateTimeField(default=datetime.now,verbose_name='添加时间')

    class Meta:
        verbose_name = u"'轮播图'"
        verbose_name_plural=verbose_name